Use clear_page() wherever possible/reasonable instead of open coded
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 20 Jun 2007 14:33:14 +0000 (15:33 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 20 Jun 2007 14:33:14 +0000 (15:33 +0100)
memset() calls (likewise a few replacements memcpy -> copy_page).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
13 files changed:
xen/arch/ia64/xen/domain.c
xen/arch/ia64/xen/xenmem.c
xen/arch/x86/apic.c
xen/arch/x86/domain.c
xen/arch/x86/domain_build.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/svm/vmcb.c
xen/arch/x86/hvm/vlapic.c
xen/arch/x86/hvm/vmx/vmcs.c
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/x86_32/traps.c
xen/arch/x86/x86_64/traps.c
xen/common/grant_table.c

index f85214e4b67d66d21b5f6b9f5ae232926f616184..c9bd12d432421f87f62b6e277b737132897649a9 100644 (file)
@@ -1146,9 +1146,8 @@ static void __init loaddomainelfimage(struct domain *d, struct elf_binary *elf,
                        dom_imva = __va_ul(page_to_maddr(p));
                        if (filesz > 0) {
                                if (filesz >= PAGE_SIZE)
-                                       memcpy((void *) dom_imva,
-                                              (void *) elfaddr,
-                                              PAGE_SIZE);
+                                       copy_page((void *) dom_imva,
+                                                 (void *) elfaddr);
                                else {
                                        // copy partial page
                                        memcpy((void *) dom_imva,
@@ -1166,7 +1165,7 @@ static void __init loaddomainelfimage(struct domain *d, struct elf_binary *elf,
                        }
                        else if (memsz > 0) {
                                 /* always zero out entire page */
-                               memset((void *) dom_imva, 0, PAGE_SIZE);
+                               clear_page((void *) dom_imva);
                        }
                        memsz -= PAGE_SIZE;
                        filesz -= PAGE_SIZE;
@@ -1367,7 +1366,7 @@ int __init construct_dom0(struct domain *d,
        if (start_info_page == NULL)
                panic("can't allocate start info page");
        si = page_to_virt(start_info_page);
-       memset(si, 0, PAGE_SIZE);
+       clear_page(si);
        snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-ia64",
                xen_major_version(), xen_minor_version());
        si->nr_pages     = max_pages;
index 54cc21be7b45bfcec09632a8debfaec51c8b4f35..47c3742eee75fdb588f2b6367772b0971a18fae1 100644 (file)
@@ -90,7 +90,7 @@ alloc_dir_page(void)
                panic("Not enough memory for virtual frame table!\n");
        ++table_size;
        dir = mfn << PAGE_SHIFT;
-       memset(__va(dir), 0, PAGE_SIZE);
+       clear_page(__va(dir));
        return dir;
 }
 
index f934a305060b03c82580fb66970b68b86d531132..3c6a14d43c814331b37c502142d998662a3e31ee 100644 (file)
@@ -817,7 +817,7 @@ void __init init_apic_mappings(void)
      */
     if (!smp_found_config && detect_init_APIC()) {
         apic_phys = __pa(alloc_xenheap_page());
-        memset(__va(apic_phys), 0, PAGE_SIZE);
+        clear_page(__va(apic_phys));
     } else
         apic_phys = mp_lapic_addr;
 
@@ -852,7 +852,7 @@ void __init init_apic_mappings(void)
             } else {
 fake_ioapic_page:
                 ioapic_phys = __pa(alloc_xenheap_page());
-                memset(__va(ioapic_phys), 0, PAGE_SIZE);
+                clear_page(__va(ioapic_phys));
             }
             set_fixmap_nocache(idx, ioapic_phys);
             apic_printk(APIC_VERBOSE, "mapped IOAPIC to %08lx (%08lx)\n",
index 63364b0e8e6ed1d08af4c71794164f42be43c609..79dc4baa370fcf7922cc7e9def2e15bf5a5688a2 100644 (file)
@@ -476,7 +476,7 @@ int arch_domain_create(struct domain *d)
         if ( (d->shared_info = alloc_xenheap_page()) == NULL )
             goto fail;
 
-        memset(d->shared_info, 0, PAGE_SIZE);
+        clear_page(d->shared_info);
         share_xen_page_with_guest(
             virt_to_page(d->shared_info), d, XENSHARE_writable);
     }
index dffa7ce3459e82a68adaa697b6be2e877ea58e0c..e57e33e617e4336792c25ce3139b0b58806c749a 100644 (file)
@@ -505,7 +505,7 @@ int __init construct_dom0(
     v->arch.guest_table = pagetable_from_paddr((unsigned long)l3start);
 #else
     l2start = l2tab = (l2_pgentry_t *)mpt_alloc; mpt_alloc += PAGE_SIZE;
-    memcpy(l2tab, idle_pg_table, PAGE_SIZE);
+    copy_page(l2tab, idle_pg_table);
     l2tab[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] =
         l2e_from_paddr((unsigned long)l2start, __PAGE_HYPERVISOR);
     v->arch.guest_table = pagetable_from_paddr((unsigned long)l2start);
@@ -645,7 +645,7 @@ int __init construct_dom0(
             panic("Not enough RAM for domain 0 PML4.\n");
         l4start = l4tab = page_to_virt(page);
     }
-    memcpy(l4tab, idle_pg_table, PAGE_SIZE);
+    copy_page(l4tab, idle_pg_table);
     l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] =
         l4e_from_paddr(__pa(l4start), __PAGE_HYPERVISOR);
     l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] =
@@ -823,7 +823,7 @@ int __init construct_dom0(
 
     /* Set up start info area. */
     si = (start_info_t *)vstartinfo_start;
-    memset(si, 0, PAGE_SIZE);
+    clear_page(si);
     si->nr_pages = nr_pages;
 
     si->shared_info = virt_to_maddr(d->shared_info);
index 1dfbfd763f44a411910c4a34448f49f877d31218..9275a0105236cf58213f427e9c27d744848cebb8 100644 (file)
@@ -766,8 +766,6 @@ static void svm_init_hypercall_page(struct domain *d, void *hypercall_page)
     char *p;
     int i;
 
-    memset(hypercall_page, 0, PAGE_SIZE);
-
     for ( i = 0; i < (PAGE_SIZE / 32); i++ )
     {
         p = (char *)(hypercall_page + (i * 32));
index a459f2ca09578aa6901f28c5da8d6e537fd11760..c6b1ccddea7ff6cf9cf12d9d1f286b948a7ae79f 100644 (file)
@@ -56,7 +56,7 @@ struct vmcb_struct *alloc_vmcb(void)
         return NULL;
     }
 
-    memset(vmcb, 0, PAGE_SIZE);
+    clear_page(vmcb);
     return vmcb;
 }
 
@@ -72,11 +72,11 @@ struct host_save_area *alloc_host_save_area(void)
     hsa = alloc_xenheap_page();
     if ( hsa == NULL )
     {
-        printk(XENLOG_WARNING "Warning: failed to allocate vmcb.\n");
+        printk(XENLOG_WARNING "Warning: failed to allocate hsa.\n");
         return NULL;
     }
 
-    memset(hsa, 0, PAGE_SIZE);
+    clear_page(hsa);
     return hsa;
 }
 
index 99ca28740046eda30ab805f130ddc136abe0580a..98d346f85a06afbed04b096bea7c8034541277f9 100644 (file)
@@ -934,7 +934,7 @@ int vlapic_init(struct vcpu *v)
        return -ENOMEM;
     }
 
-    memset(vlapic->regs, 0, PAGE_SIZE);
+    clear_page(vlapic->regs);
 
     vlapic_reset(vlapic);
 
index 6ca6a4e9b88c8c06e15913632b6781211f791033..1740277c8e060447f147f4695f12d94c130a3837 100644 (file)
@@ -158,7 +158,7 @@ static struct vmcs_struct *vmx_alloc_vmcs(void)
         return NULL;
     }
 
-    memset(vmcs, 0, PAGE_SIZE);
+    clear_page(vmcs);
     vmcs->vmcs_revision_id = vmcs_revision_id;
 
     return vmcs;
index 74d793c445df929608775a790a18acfd2a25df13..f36b58f26169dc0ec8513fee2a91aee6e85c0db3 100644 (file)
@@ -1070,8 +1070,6 @@ static void vmx_init_hypercall_page(struct domain *d, void *hypercall_page)
     char *p;
     int i;
 
-    memset(hypercall_page, 0, PAGE_SIZE);
-
     for ( i = 0; i < (PAGE_SIZE / 32); i++ )
     {
         p = (char *)(hypercall_page + (i * 32));
index a837d7e42d25e086f5b3bb75be98cc6b1c387ff9..c3fc0fdd2af681f692f166cf9dbae4f938ec2f95 100644 (file)
@@ -513,6 +513,7 @@ static void hypercall_page_initialise_ring1_kernel(void *hypercall_page)
 
 void hypercall_page_initialise(struct domain *d, void *hypercall_page)
 {
+    memset(hypercall_page, 0xCC, PAGE_SIZE);
     if ( is_hvm_domain(d) )
         hvm_hypercall_page_initialise(d, hypercall_page);
     else if ( supervisor_mode_kernel )
index e23ed82c758bc347c5ac44df1be6be22c99c025d..6b14040a14560ff10d8d23c6b174ed4ac6bd5239 100644 (file)
@@ -510,6 +510,7 @@ static void hypercall_page_initialise_ring3_kernel(void *hypercall_page)
 
 void hypercall_page_initialise(struct domain *d, void *hypercall_page)
 {
+    memset(hypercall_page, 0xCC, PAGE_SIZE);
     if ( is_hvm_domain(d) )
         hvm_hypercall_page_initialise(d, hypercall_page);
     else if ( !is_pv_32bit_domain(d) )
index d6581f66cfe7885a394749934ebb3952d469c39c..15e72aea7c76fc7f8e1eee56de51b25ef3021076 100644 (file)
@@ -148,7 +148,7 @@ get_maptrack_handle(
                 return -1;
             }
 
-            memset(new_mt, 0, PAGE_SIZE);
+            clear_page(new_mt);
 
             new_mt_limit = lgt->maptrack_limit + MAPTRACK_PER_PAGE;
 
@@ -624,7 +624,7 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames)
     {
         if ( (gt->active[i] = alloc_xenheap_page()) == NULL )
             goto active_alloc_failed;
-        memset(gt->active[i], 0, PAGE_SIZE);
+        clear_page(gt->active[i]);
     }
 
     /* Shared */
@@ -632,7 +632,7 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames)
     {
         if ( (gt->shared[i] = alloc_xenheap_page()) == NULL )
             goto shared_alloc_failed;
-        memset(gt->shared[i], 0, PAGE_SIZE);
+        clear_page(gt->shared[i]);
     }
 
     /* Share the new shared frames with the recipient domain */
@@ -1365,7 +1365,7 @@ grant_table_create(
     {
         if ( (t->active[i] = alloc_xenheap_page()) == NULL )
             goto no_mem_2;
-        memset(t->active[i], 0, PAGE_SIZE);
+        clear_page(t->active[i]);
     }
 
     /* Tracking of mapped foreign frames table */
@@ -1375,7 +1375,7 @@ grant_table_create(
     memset(t->maptrack, 0, max_nr_maptrack_frames() * sizeof(t->maptrack[0]));
     if ( (t->maptrack[0] = alloc_xenheap_page()) == NULL )
         goto no_mem_3;
-    memset(t->maptrack[0], 0, PAGE_SIZE);
+    clear_page(t->maptrack[0]);
     t->maptrack_limit = PAGE_SIZE / sizeof(struct grant_mapping);
     for ( i = 0; i < t->maptrack_limit; i++ )
         t->maptrack[0][i].ref = i+1;
@@ -1389,7 +1389,7 @@ grant_table_create(
     {
         if ( (t->shared[i] = alloc_xenheap_page()) == NULL )
             goto no_mem_4;
-        memset(t->shared[i], 0, PAGE_SIZE);
+        clear_page(t->shared[i]);
     }
 
     for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ )